package com.cro.fnal;

import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        String[] names = new String[]{"Mike","Ellie","Fatma","Rohan"};
        String[] colors = new String[]{"red","purple","blue","green"};

        //先确定名字和颜色的所有集合
        ArrayList<AStatu> status = new ArrayList<>();
        for (int i = 0; i < 4; i++) {   //(0,i)
            NameAndColor point1 = new NameAndColor(0, i);
            for (int j = 0; j < 4; j++) { //(1,j)
                if (j == i) continue;
                NameAndColor point2 = new NameAndColor(1, j);
                for (int k = 0; k < 4; k++) {  //(2,k)
                    if (k == i || k == j) continue;
                    NameAndColor point3 = new NameAndColor(2, k);
                    for (int l = 0; l < 4; l++) {   //(3,l)
                        if (l == i || l == j || l == k) continue;
                        NameAndColor point4 = new NameAndColor(3, l);
                        AStatu aStatu = new AStatu(point1, point2, point3, point4);
                        status.add(aStatu);
                    }
                }
            }
        }
        //颜色和名字的集合确定

        System.out.println(status.size());
        int count =0;
        for (AStatu aStatu : status) {//每一个结果集顺序固定，安排不同的名次，在最内环进行判断（判断另写方法）

            Player[] players = new Player[]{new Player(),new Player(),new Player(),new Player()};
            for (int i = 0; i < 4; i++) {
                setPlayer(players[0],aStatu,0,i);
                for (int j = 0; j < 4; j++) {
                    if(j==i)continue;
                    setPlayer(players[1],aStatu,1,j);
                    for (int k = 0; k < 4; k++) {
                        if(k==i||k==j)continue;
                        setPlayer(players[2],aStatu,2,k);
                        for (int l = 0; l < 4 ; l++) {
                            if(l==i||l==j||l==k)continue;
                            setPlayer(players[3],aStatu,3,l);
                            count++;
                            //开始判断是否达成条件
                            if(judge(players))
                            {
                                for (int m = 0; m < 4; m++) {
                                    System.out.println(players[m]);
                                }
                            }
                        }
                    }
                }
            }
        }

    }
    public static void setPlayer(Player player,AStatu statu,int node,int score)
    {
        NameAndColor[] theCollection = statu.getStatu();
        String[] names = new String[]{"Mike","Ellie","Fatma","Rohan"};
        String[] colors = new String[]{"red","purple","blue","green"};
        player.setName(names[theCollection[node].getName()]);
        player.setColor(colors[theCollection[node].getColor()]);
        player.setScore(score);
    }
    public static boolean judge(Player[] players)
    {
        if(getPlayerByName(players,"Ellie").getColor().equals("purple")&&
           !(getPlayerByColor(players,"green").getName().equals("Rohan")))
        {
            if(
                getPlayerByName(players,"Mike").getScore()!=0&&
                getPlayerByName(players,"Mike").getScore()!=3&&
                getPlayerByName(players,"Ellie").getScore()!=0&&
                getPlayerByName(players,"Ellie").getScore()!=3)
            {
                if(getPlayerByColor(players,"blue").getScore()<getPlayerByName(players,"Fatma").getScore())
                {
                    if (getPlayerByColor(players,"green").getScore()<getPlayerByColor(players,"purple").getScore())
                    {
                        return true;
                    }
                }
                return false;
            }
            return false;
        }
        return false;
    }
    public static Player getPlayerByName(Player[] players,String name)
    {
        for (Player player : players) {
            if(player.getName().equals(name))return player;
        }
        return null;
    }

    public static Player getPlayerByColor(Player[] players,String color)
    {
        for (Player player : players) {
            if(player.getColor().equals(color))return player;
        }
        return null;
    }
//    public static Player getPlayerByScore(ArrayList<Player> AllPlayer,int i)
//    {
//
//    }
}
class NameAndColor{
    private int name;
    private int color;

    public NameAndColor(int name, int color) {
        this.name = name;
        this.color = color;
    }

    public int getName() {
        return name;
    }

    public void setName(int name) {
        this.name = name;
    }

    public int getColor() {
        return color;
    }

    public void setColor(int color) {
        this.color = color;
    }
}
class AStatu{
    NameAndColor[] aStatu = new NameAndColor[4];

    public AStatu(){}
    public AStatu(NameAndColor point1,NameAndColor point2,NameAndColor point3,NameAndColor point4) {
        aStatu[0]=point1;
        aStatu[1]=point2;
        aStatu[2]=point3;
        aStatu[3]=point4;
    }
    public NameAndColor[] getStatu()
    {
        return aStatu;
    }

}